#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define all(x) (x).begin(),(x).end()
typedef long long ll;

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<VI> VVI;

typedef pair<int,int> PII;
typedef vector<PII> VPII;
#define X first
#define Y second
#define mp make_pair

#define two(x) (1<<(x))
#define twoll(x) ((long long)1<<(x))
#define contain(s,x) (((s)&two(x))!=0)
#define containll(s,x) (((s)&twoll(x))!=0)

#define db(a) cout << #a << "=" << a << " "
#define dbn cout << endl
#define sqr(x) (x)*(x)

string STR(int n) { char tmp[20]; sprintf(tmp,"%d",n); return tmp; }
int INT(string s) { return atoi(s.c_str()); }
template <class Ty, class Tx> Ty to(const Tx &x) { Ty y; stringstream ss; ss<<x; ss>>y; return y; }

const int INF = 1000000007;
const double EPS = 1e-10;

char buf[1<<16];
int TC;

int N,M;
int G[100][100];
int cnt[10001];

int calc() {
	bool pos, ok;
	VI v;
	for (int i = 0; i < N; ++i) {
		pos = 0, ok = 1;
		map<int,int> MP;
		for (int j = 0; j < M; ++j)
			if (G[i][j]) {
				pos = 1;
				MP[G[i][j]]++;
				if (MP.size() > 1) {
					ok = 0;
					break;
				}
			}
		if (pos && ok && cnt[MP.begin()->first] == MP.begin()->second)
			v.push_back(MP.begin()->first);
	}
	for (int i = 0; i < M; ++i) {
		pos = 0, ok = 1;
		map<int,int> MP;
		for (int j = 0; j < N; ++j)
			if (G[j][i]) {
				pos = 1;
				MP[G[j][i]]++;
				if (MP.size() > 1) {
					ok = 0;
					break;
				}
			}
		if (pos && ok && cnt[MP.begin()->first] == MP.begin()->second)
			v.push_back(MP.begin()->first);
	}
	sort(all(v));
	if (v.size()) {
		return v.back();
	}
	else
		return 0;
}

int main() {
#define SUBMIT 1
#if !SUBMIT
	freopen("DATA.in","r",stdin);
#endif

	while (cin>>N>>M) {
		if (N == 0 && M == 0) break;
		memset(cnt,0,sizeof(cnt));
		for (int i = 0; i < N; ++i)
			for (int j = 0; j < M; ++j) {
				cin >> G[i][j];
				cnt[G[i][j]]++;
			}
		int next = calc();
		VI seq;
		while (next) {
			seq.push_back(next);
			
			for (int i = 0; i < N; ++i)
				for (int j = 0; j < M; ++j)
					if (G[i][j] == next)
						G[i][j] = 0;
			
			next = calc();
		}
		for (int i = seq.size()-1; i >= 0; --i) {
			cout << seq[i];
			if (i != 0) cout << " ";
		}
		cout << endl;
	}

	return 0;
}





